package com.example.hangzhou.welbeing.mytestdemoapp.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;

import com.example.hangzhou.welbeing.mytestdemoapp.R;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 杭州惟君医疗科技有限公司09
 * Created by 20433 on 2018/5/8
 *
 * @desc 东风山河绿，春已不折柳，繁花看不尽，处处惹人留
 * @desc 佛祖镇楼，bug辟容易
 */

public class RotateFragment extends Fragment {

    @Bind(R.id.fragment_home_pager_effect_iv_planet_one)
    ImageView fragmentHomePagerEffectIvPlanetOne;
    @Bind(R.id.layout_traditional_animation_rotate_button1)
    Button layoutTraditionalAnimationRotateButton1;
    @Bind(R.id.layout_traditional_animation_rotate_button2)
    Button layoutTraditionalAnimationRotateButton2;
    @Bind(R.id.layout_traditional_animation_rotate_button3)
    Button layoutTraditionalAnimationRotateButton3;
    @Bind(R.id.layout_traditional_animation_rotate_button4)
    Button layoutTraditionalAnimationRotateButton4;
    @Bind(R.id.layout_traditional_animation_rotate_button5)
    Button layoutTraditionalAnimationRotateButton5;
    private Context mcontext;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        mcontext = context;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = View.inflate(mcontext, R.layout.layout_traditional_animation_rotate, null);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    @OnClick({R.id.fragment_home_pager_effect_iv_planet_one, R.id.layout_traditional_animation_rotate_button1, R.id.layout_traditional_animation_rotate_button2, R.id.layout_traditional_animation_rotate_button3, R.id.layout_traditional_animation_rotate_button4, R.id.layout_traditional_animation_rotate_button5})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.fragment_home_pager_effect_iv_planet_one:
                break;
            case R.id.layout_traditional_animation_rotate_button1:
               Animation alphaAnimation =  AnimationUtils.loadAnimation(mcontext,R.anim.rotate_alpha);
                fragmentHomePagerEffectIvPlanetOne.startAnimation(alphaAnimation);
                break;
            case R.id.layout_traditional_animation_rotate_button2:
                Animation translateAnimation   =  AnimationUtils.loadAnimation(mcontext,R.anim.rotate_translate);
                fragmentHomePagerEffectIvPlanetOne.startAnimation(translateAnimation);
                break;
            case R.id.layout_traditional_animation_rotate_button3:
                Animation scaleAnimation   =    AnimationUtils.loadAnimation(mcontext,R.anim.rotate_scale);
                fragmentHomePagerEffectIvPlanetOne.startAnimation(scaleAnimation);
                break;
            case R.id.layout_traditional_animation_rotate_button4:
                Animation rotateAnimation   =     AnimationUtils.loadAnimation(mcontext,R.anim.rotate_one);
                fragmentHomePagerEffectIvPlanetOne.startAnimation(rotateAnimation);
                break;
            case R.id.layout_traditional_animation_rotate_button5:
                Animation setAnimation   =   AnimationUtils.loadAnimation(mcontext,R.anim.rotate_set);
                fragmentHomePagerEffectIvPlanetOne.startAnimation(setAnimation);
                break;
        }
    }
}
